<template>
    <div>
        <div class="outmain ba_f">
            <div class="shuju_title mar_b20">
                <div class="shuju_title_text">
                    <span>用户设置</span>
                </div>
            </div>
            <el-form ref="form" :model="form" label-width="180px">
                <el-form-item label="手机号验证">
                    <el-radio-group v-model="form.payType">
                        <el-radio label="1">开启</el-radio>
                        <el-radio label="2">关闭</el-radio>
                    </el-radio-group>
                    <div class="yb_margin lh16">开启后，用户在下单的时候需要先绑定手机号，才能进行下一步操作</div>
                </el-form-item>
<!--                <el-form-item label="登录需要绑定手机号">-->
<!--                    <el-radio-group v-model="form.loginType">-->
<!--                        <el-radio label="1">开启</el-radio>-->
<!--                        <el-radio label="2">关闭</el-radio>-->
<!--                    </el-radio-group>-->
<!--                </el-form-item>-->
            </el-form>
        </div>
        <div class="mar_t20 ba_f pad_20 t_c">
            <el-button type="primary" @click="submitForm">保存</el-button>
        </div>
    </div>
</template>
<script>
    import {getMemberSetInfo, memberSet} from "@/api/user";

    export default {
        created() {
            this.bus.$emit('loading', true);
            this.init();
        },
        data() {
            return {
                form: {
                    payType: '',
                    loginType: '',
                    id: '',
                },
            }
        },
        methods: {
            async init() {
                const {data} = await getMemberSetInfo();
                this.form = Object.assign({}, data);
                this.bus.$emit('loading', false)
            },
            submitForm() {
                this.$refs["form"].validate(async (valid) => {
                    if (valid) {
                        const {msg} = await memberSet(this.form);
                        this.$baseMessage(msg, "success");
                        this.init();
                    } else {
                        return false;
                    }
                });
            },
        }
    }
</script>
